//! \file UiMenu.c
//! \brief TODO: Document
// -----------------------------------------------------------------------------
//! This program is free software; you can redistribute it and/or
//! modify it under the terms of the GNU General Public License
//! as published by the Free Software Foundation; either version 2
//! of the License, or (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program; if not, write to the Free Software Foundation,
//! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// -----------------------------------------------------------------------------

#include <agar/core.h>
#include <agar/gui.h>
#include "UiMenu.h"
#include "UiWindowAbout.h"

// =====[ Local Definitions ]===================================================

// =====[ Local DataTypes ]=====================================================

// =====[ Local Variables ]=====================================================

// =====[ Local Functions ]=====================================================
static void _UI_MenuQuit(AG_Event *event);
static void _UI_MenuAbout(AG_Event *event);

// =====[ Private (Internal) Methods ]==========================================

// =====[ Local Implementation ]================================================


// =============================================================================
// Implement: UI_MenuNew
// -----------------------------------------------------------------------------
tERROR UI_MenuNew(AG_Widget *pParent)
{
  AG_Menu *pMenu;
  AG_MenuItem *pMenuItem;

  // Validate our arguments. TOOD: ???

  // Create the menu.
  pMenu = AG_MenuNew(pParent, 0);

  // Add the [File] menu item.
  pMenuItem = AG_MenuNode(pMenu->root, "File", NULL);
  {
//    AG_MenuAction(pMenuItem, "Load", NULL, _DoNothing, NULL);
//    AG_MenuAction(pMenuItem, "Save", NULL, _DoNothing, NULL);
    AG_MenuAction(pMenuItem, "Quit", NULL, _UI_MenuQuit, NULL);
  }

  // Add the [Help] menu item.
  pMenuItem = AG_MenuNode(pMenu->root, "Help", NULL);
  {
    AG_MenuAction(pMenuItem, "About", NULL, _UI_MenuAbout, NULL);
  }

  // TODO: error checking?
}


// =============================================================================
// _UI_MenuQuit
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
// -----------------------------------------------------------------------------
static void _UI_MenuQuit(AG_Event *event)
{
  AG_QuitGUI();
}

// =============================================================================
// _UI_MenuQuit
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
// -----------------------------------------------------------------------------
static void _UI_MenuAbout(AG_Event *event)
{
  UI_WindowAboutNew();

}

